import { myEnv } from '@/myEnv';
import { mergeRequest } from '@/utils';
import { CollectionList_Web, CollectionList_Res } from '@/pages/_server/_class/MyCollection/CollectionList';
/** 获得收藏列表 */
export const apiGetCollectionList = async () => {
    const response1: MyResponse<CollectionList_Res[]> = await sendRequest();
    if (!response1) return;
    const webData = response1.data.map((item) => {
        return new CollectionList_Web().immit_response(item);
    });
    const resonlse2: MyResponse<CollectionList_Web[]> = { ...response1, data: webData };
    return resonlse2;
};

const sendRequest = async () => {
    let response1: MyResponse<CollectionList_Res[]>;
    if (myEnv.IS_ON_LINE) {
        response1 = await mergeRequest({
            url: 'user/get-all-favorite-goods',
            method: 'GET',
        });
    } else {
        response1 = {
            "code": "200",
            "message": "ok",
            "data": [
              {
                "id": "1",
                "artworkId": "1",
                "artistId": "1",
                "artworkIconUrl": "/nft-icon/p2.png",
                "name": "猪面",
                "dropStartDate": "2022-09-03T08:00:00.000Z",
                "dropEndDate": "2022-09-10T08:00:00.000Z",
                "totalQuantity": "1000",
                "leftQuantity": "500",
                "price": "30.05",
                "status": "soldOut",
                "likes": '1',
                "artworkIntro": "这是梵高的作品..................................................................."
              },
              {
                "id": "2",
                "artworkId": "2",
                "artistId": "1",
                "artworkIconUrl": "/nft-icon/p3.jpg",
                "name": "artboy",
                "dropStartDate": "2022-09-03T08:00:00.000Z",
                "dropEndDate": "2022-09-10T08:00:00.000Z",
                "totalQuantity": "100",
                "leftQuantity": "100",
                "price": "30.05",
                "status": "soldOut",
                "likes": '1',
                "artworkIntro": "这是梵高的作品..................................................................."
              }
            ]
          };
    }
    return response1;
};
